import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'


Vue.use(VueRouter)

//引入静态页面
import Layout from '@/views/layout/Layout.vue'

const routes: Array<RouteConfig> = [
  {
    path: '/',
    redirect: '/home'
  },
  //首页
  {
    path: '/home',
    component: Layout,
    redirect: '/home/goods',//重定向到商品
    children: [
      {
        path: '/home/goods',//商品
        component: () => import('@/views/goods/Goods.vue')
      },
      {
        path: '/home/shop',//店铺
        component: () => import('@/views/shop/Shop.vue')
      },
      {
        path: '/home/comment',//评论
        component: () => import('@/views/comment/Comment.vue')
      },
    ]

  },
  //详情页
  {
    path: '/details',
    component: () => import('@/views/details/Details.vue')
  },
  //错误
  {
    path: '*',
    component: () => import('../views/error-404/Error404.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
